// 示例代码
import { createApp } from 'vue'
import { createStore } from 'vuex'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/es/locale/lang/zh-cn'; // 引入中文语言包
import App from './App.vue'


// 保存数据
// 创建一个新的 store 实例
const store = createStore({
  state: {
    stockCode: '600733',
    stockName: '北汽蓝谷',
    stockTime: '2023-05-17',
  },
  mutations: {
    SET_STOCK_CODE(state, code) {
      state.stockCode = code;
    },
    SET_STOCK_NAME(state, name) {
      state.stockName = name;
    },
    SET_STOCK_TIME(state, time) {
      state.stockTime = time;
    }
  },
  actions: {
    changeStockCode({ commit }, code) {
      commit('SET_STOCK_CODE', code);
    },
    changeStockName({ commit }, name) {
      commit('SET_STOCK_NAME', name);
    },
    changeStockTime({ commit }, time) {
      commit('SET_STOCK_TIME', time);
    }
  },
  getters: {
    getStockCode: state => state.stockCode,
    getStockName: state => state.stockName,
    getStockTime: state => state.stockTime,
  }
})

const app = createApp(App)

// 将 store 实例作为插件安装
app.use(store)

// 注册所有 Element Plus 图标
Object.keys(ElementPlusIconsVue).forEach(key => {
    app.component(key, ElementPlusIconsVue[key]);
  });
app.use(ElementPlus, {
  locale: zhCn, // 设置全局语言为中文
});

app.mount('#app')






